﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TWS07
    {
        public TWS07()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWAFARBEN();
            DataContext = MV;
            InitializeComponent();
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            base.Window_Loaded(sender, e);
        }
        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 32)
                return;
             
            dwData = TBMain.NewRow();
            dwData["WAFMANDANT"] = app.Mandant;
            dwData["WAFART"] = EXAUF.Substring(1, 20);
            dwData["WAFVAR"] = EXAUF.Substring(22, 2);//从VF过来，因为纱线是3个VAR长度
           
            switch(ZUART)
            {
                case "C":
                case "F":
                    dwData["WAFZUART"] =ZUART;
                    dwData["WAFZUSATZ"] = EXAUF.Substring(23, 10);
                    SResult = TMV.QWAF01(dwData); 
                    break;
                case "B":
                    dwData["WAFZUART"] = "B";
                    if (EXAUF.Length >= 42)
                    {

                        dwData["WAFZUSATZ"] = EXAUF.Substring(33, 10);
                    }
                    else
                    {
                        dwData["WAFZUSATZ"] = "";
                    }
                    SResult = TMV.QWAF01(dwData);
                    break;
                case "D":
                    dwData["WAFZUART"] = ZUART;
                    dwData["WAFZUSATZ"] = EXAUF.PadRight(100).Substring(43, 10);
                    dwData["WAFCOLORIT"] = " AND WAFCOLORIT='" + EXAUF.PadRight(100).Substring(53, 10)+"'";
                    SResult = TMV.QWAF01(dwData);
                    break;
            } 
            MergeData(SResult, true);
            base.OnEXAUFChg(vlaue);
        }
        
    }
}
